package com.autohammal.factory;

import java.util.Date;

import com.autohammal.monitor.scheduler.Scheduler;
import com.autohammal.monitor.scheduler.implement.AdvanceScheduler;
import com.autohammal.monitor.scheduler.implement.SimpleMonitorScheduler;
import com.autohammal.monitor.scheduler.implement.WorkDaysScheduler;
import com.autohammal.monitor.scheduler.support.SchedulerTime;
import com.autohammal.monitor.scheduler.support.SchedulerUnit;

public class SchedulerFactory {

	public static Scheduler makeScheduler(long delay, long period) {
		SimpleMonitorScheduler sms = new SimpleMonitorScheduler();
		sms.setScheduleUnit(SchedulerUnit.atSimpleFixedRate(
				delay + System.currentTimeMillis(), period));
		return sms;
	}

	public static Scheduler makeScheduler(Date startDate, long period) {
		SimpleMonitorScheduler sms = new SimpleMonitorScheduler();
		sms.setScheduleUnit(SchedulerUnit.atSimpleFixedRate(
				startDate.getTime(), period));
		return sms;
	}

	public static Scheduler makeSSchedulerWithDelay(long initialDelay,
			long delay) {
		AdvanceScheduler as = new AdvanceScheduler();
		as.setScheduleUnit(SchedulerUnit.withAdvanceFixedDelay(initialDelay,
				delay));
		return as;
	}

	public static Scheduler makeSSchedulerAtRate(long initialDelay, long period) {
		AdvanceScheduler as = new AdvanceScheduler();
		as.setScheduleUnit(SchedulerUnit.atAdvanceFixedRate(initialDelay,
				period));
		return as;
	}

	public static Scheduler makeWorkDaysScheduler(SchedulerTime scheduletime,
			Integer... holidate) {
		WorkDaysScheduler wds = new WorkDaysScheduler();
		wds.setTime(new SchedulerTime(14, 06, 00));
		wds.setHolidays(holidate);
		return wds;
	}

	public static Scheduler makeWorkDaysScheduler(SchedulerTime scheduletime) {
		WorkDaysScheduler wds = new WorkDaysScheduler();
		wds.setTime(new SchedulerTime(14, 06, 00));
		wds.setHolidays(1, 7);
		return wds;
	}

}
